<form onsubmit="return submit_co()" action="<?= base_url('admin/dokumen/proses'); ?>" method="post" enctype="multipart/form-data">
	<div class="row">
		<div class="col s12 m12">
			<div class="card">
				<div class="card-content">
					<div class="row">
						<div class="col m6">
							<div>
								<label>Judul</label>
								<input type="text" name="judul" required="required" placeholder="judul" maxlength="255">
							</div>
							<div>
								<label>Mapel</label>
					      			<select class='select' name="XKodeMapel" required="required">
					      				<?php
					      				foreach ($this->db->get('cbt_mapel')->result() as $key => $value) {
					      					?>
					      					<option value="<?= $value->XKodeMapel; ?>"><?= $value->XKodeMapel." | ".$value->XNamaMapel; ?></option>
					      					<?php
					      				}
					      				?>
					      			</select>
							</div>
							<div style="display: none;">
								<label>Kirim Ke</label>
					      			<select class='select' name="share[]"  multiple="multiple">
					      				<?php
					      				foreach ($this->db->get('cbt_user')->result() as $key => $value) {
					      					?>
					      					<option value="<?= $value->Username; ?>"><?= $value->Nama ?></option>
					      					<?php
					      				}
					      				?>
					      			</select>
					      			<small class="blue-text">Pilih siapa yang dapat melihat dokumen anda</small>
							</div>
						</div>
						<div class="col m6">
							<div>
								<label>Keterangan</label>
								<textarea name="keterangan" placeholder="Keterangan" class="materialize-textarea"></textarea>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="col s12 m12">
			<div class="row">
				<div class="col s12 m8">
					<div class="card-panel">
						<!-- <div class="card-content"> -->
							<span>File dilampirkan</span>
							<div class="" id="fileDefault"></div>
							<div class="file-field input-field">
								<div class="btn blue btn-small">
									<span><i class="material-icons">add</i></span>
									<input  autocomplete="off" type="file" name="files[]"  multiple="multiple">
								</div>
								<div class="file-path-wrapper">
							        <input  autocomplete="off" class="file-path validate" type="text">
							     </div>
							</div>
						<!-- </div> -->
					</div>

				</div>

				<div class="col s12 m4">
					<div class="card-panel blue white-text">
						<b>Format file yang diperbolehkan :</b> <br>
						<i>gif, jpg, png, mp3, wav, mp4, avi, pdf, xls, xlsx, doc, docx, pdf, ppt, pptx, zip</i>
					</div>
				</div>

			</div>
		</div>
	</div>
	
	<div class="card-panel" id="submit">
		<?= $this->m_config->pesan(); ?>
		<button  type="submit" class="btn green">Simpan Berkas</button>
		<div class="fixed-action-btn" style="top: 10%; bottom: auto">
			<button  type="submit" class="btn btn-floating green btn-large"><i class="material-icons">save</i></button>
		</div>
		<a href="<?= base_url("admin/dokumen"); ?>" class="btn red">Kembali</a>
	</div>
</form>


<?php
if (isset($u)) {
	?>
	<script type="text/javascript">
		$(function() {
			$('[name="judul"]').val('<?= $u->judul; ?>');
			$('[name="keterangan"]').val('<?= $u->keterangan; ?>');
			$('[name="XKodeMapel"]').val('<?= $u->XKodeMapel; ?>');
			<?php foreach (json_decode($u->file) as $file): ?>
				$('#fileDefault').append('<div></div>');
			<?php endforeach ?>
		});
	</script>
	<?php
}
?>